

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv=Content-Type content='text/html; charset=utf-8'>
<title>

</title></head>
<body style="margin-top: 0px; margin-left: 0px">
    <form name="form1" method="post" action="fi000015..htm" tppabs="http://www.boopharm.com/plugin/ThirdPartyPluginAspects/Amap/amap.aspx?em=false&w=666&h=267&lng=105.48111&lat=29.422853&zoom=10&aspectid=d22763196762a9%3f__VIEWSTATE%3d%2fwEPDwUKLTUzMTk2NTgwOWRkuGSCxQFXC78n2qhaWYIHPgIHyDQ%3d&hidData=&hidCenterLat=&hidCenterLng=&hidZoom=?__VIEWSTATE=/wEPDwUKLTUzMTk2NTgwOWRkuGSCxQFXC78n2qhaWYIHPgIHyDQ=&__EVENTVALIDATION=/wEWBQLh0tmEAwKc2ujFAwLhg66aDQLokb/jDgKO/8ueD1AIKi1X8dVV9gtPSbgQT9Jn9mBd&hidData=&hidCenterLat=&hidCenterLng=&hidZoom=" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTUzMTk2NTgwOWRkuGSCxQFXC78n2qhaWYIHPgIHyDQ=" />
</div>

<div>

	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBQLh0tmEAwKc2ujFAwLhg66aDQLokb/jDgKO/8ueD1AIKi1X8dVV9gtPSbgQT9Jn9mBd" />
</div>
        <script type="text/javascript" language="javascript" src="../../../../res.mynet.cn/jscss/48_115_all_min.js" tppabs="http://res.mynet.cn/jscss/48_115_all_min.js"></script>
    <script language="javascript" src="../../../../webapi.amap.com/maps-v=1.2&key=00c989a504eff74a6db6660370f2cf80.js" tppabs="http://webapi.amap.com/maps?v=1.2&key=00c989a504eff74a6db6660370f2cf80"></script>
    <script language="javascript" src="Base64.js" tppabs="http://www.boopharm.com/plugin/ThirdPartyPluginAspects/Amap/Base64.js"></script>
    <script language="javascript">
        var makerlist = new Array();
        var makerobjlist = new Array();
        String.format = function () {
            if (arguments.length == 0)
                return null;

            var str = arguments[0];
            for (var i = 1; i < arguments.length; i++) {
                var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
                str = str.replace(re, arguments[i]);
            }
            return str;
        }
        Array.prototype.indexOf = function (val) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] == val) return i;
            }
            return -1;
        };
        Array.prototype.remove = function (val) {
            var index = this.indexOf(val);
            if (index > -1) {
                this.splice(index, 1);
            }
        };
        var makerobj = function (id, maker, infowindow) {
            this.Id = id;
            this.Maker = maker;
            this.InfoWindow = infowindow;
        }
        var mynetmaker = function (lng, lat, content) {
            this.Id = 0;
            this.Lng = lng;
            this.Lat = lat;
            this.Content = content;
        }

        function getpara() {
            var aspectid = getUrlParameter("aspectid");
            var methodName = parent["amapdata"+aspectid];
            var dat = methodName();
            $("#hidData").val(Base64.decode(dat));
            $("#hidZoom").val(getUrlParameter("zoom"));
            
            $("#hidCenterLng").val(getUrlParameter("lng"));
            $("#hidCenterLat").val(getUrlParameter("lat"));
            $("#map").attr("style", String.format("height:{0}px;width:{1}px", getUrlParameter("h"), getUrlParameter("w")));
            
        }
        //初始化
        function initdata() {
            if ($("#hidData").val() != "") {
                makerlist = mynet.utils.json.parse($("#hidData").val());
            }

            if ($("#hidZoom").val() != "") {
                mapObj.setZoom($("#hidZoom").val());
            }
            for (var i = 0; i < makerlist.length; i++) {
                add(makerlist[i]);
            }
            mapObj.setFitView();
            var zoom = mapObj.getZoom();
            zoom = parseInt(zoom) > parseInt($("#hidZoom").val()) ? parseInt($("#hidZoom").val()) : parseInt(zoom);
            mapObj.setZoom(zoom);
        }
        var tmp = "<textarea style='width:280px;height:100px' id='txt{1}'>{0}</textarea><input type='button' value='del' style='float:left;' makid='{1}' onclick='javascript:delmarker(this);'/><input type='button' makid='{1}' value='ok' style='float:right;' onclick='javascript:addcontent(this);'/>";

        var mapObj, tool, view, scale, currntMaker, currentInfoWindow;
        function mapInit() {
            var lng = 116.392936;
            var lat = 39.919479;
            if ($("#hidCenterLng").val() != "" && $("#hidCenterLat").val() != "") {
                lng = parseInt($("#hidCenterLng").val());
                lat = parseInt($("#hidCenterLat").val());
            }
            mapObj = new AMap.Map("map", {
                center: new AMap.LngLat(lng, lat),
                doubleClickZoom: false
            });
            mapObj.setCenter(new AMap.LngLat(lng, lat));
            //加载工具条、鹰眼
            mapObj.plugin(["AMap.ToolBar", "AMap.OverView"], function () {
                tool = new AMap.ToolBar({ autoPosition: false });
                mapObj.addControl(tool);
                view = new AMap.OverView();
                mapObj.addControl(view);
            });

            //添加点
            listener2 = AMap.event.addListener(mapObj, 'click', closeInfowidow);
            //关闭弹出窗口；
            $(document).click(closeInfowidow);
        }
        var closeInfowidow = function (e) {

            if (currentInfoWindow != null) {
                currentInfoWindow.close();
            }
        }

        var delmarker = function (e) {
            if (currntMaker != null)
                currentInfoWindow.close();
            currntMaker.setMap(null);
            var makeritem;
            for (var i = 0; i < makerlist.length; i++) {
                if (makerlist[i].Id == $(e).attr("makid")) {
                    makeritem = makerlist[i];
                    break;
                }
            }
            makerlist.remove(makeritem);
            for (var i = 0; i < makerobjlist.length; i++) {
                if (makerobjlist[i].Id == $(e).attr("makid")) {
                    makeritem = makerobjlist[i];
                    break;
                }
            }
            makerobjlist.remove(makeritem);
            //tojson();
        }
        var addcontent = function (e) {
            var makeritem;
            for (var i = 0; i < makerlist.length; i++) {
                if (makerlist[i].Id == $(e).attr("makid")) {
                    makeritem = makerlist[i];
                    break;
                }
            }
            makeritem.Content = $("#txt" + $(e).attr("makid")).val();
            currentInfoWindow.setContent(makeritem.Content);
            currentInfoWindow.close();
            //tojson();
        }
        var add = function (ma) {
            //构建点对象
            var marker = new AMap.Marker({
                map: mapObj,
                position: new AMap.LngLat(ma.Lng, ma.Lat), //基点位置
                icon: "../../../../webapi.amap.com/images/marker_sprite.png"/*tpa=http://webapi.amap.com/images/marker_sprite.png*/, //marker图标，直接传递地址url
                offset: { x: -10, y: -34 } //相对于基点的位置
            });

            var info = [];
            info.push(ma.Content+"&nbsp;");

            var inforWindow = new AMap.InfoWindow({
                offset: new AMap.Pixel(0, -34),
                size: new AMap.Size(200, 80),
                content: info.join("<br />")
            });
            currentInfoWindow = inforWindow;
            currntMaker = marker;
            AMap.event.addListener(marker, 'click', function (e) {
                currntMaker = marker;
                currentInfoWindow = inforWindow;
                inforWindow.open(mapObj, marker.getPosition());

            })

            var item = new makerobj(ma.Id, marker, inforWindow);
            makerobjlist.push(item);

            //tojson();
        }
        var addmarker = function (e) {
            var newid = parseInt(Math.random() * 100000 + 100);
            var mak = new mynetmaker(e.lnglat.getLng(), e.lnglat.getLat(), "");
            mak.Id = newid;
            makerlist.push(mak);
            add(mak);
            currentInfoWindow.open(mapObj, new AMap.LngLat(mak.Lng, mak.Lat));
        }
        var tojson = function () {
            $("#hidCenterLng").val(mapObj.getCenter().getLng());
            $("#hidCenterLat").val(mapObj.getCenter().getLat());
            $("#hidZoom").val(mapObj.getZoom());
            var listjson = mynet.utils.json.parse(makerlist);
            $("#hidData").val(listjson);
        }
        var test = function () {
            mapObj.setCenter(new AMap.LngLat($("#hidCenterLng").val(), $("#hidCenterLat").val()));
        }
        var init = function () {

            var aspectid = getUrlParameter("aspectid");
            var method = parent["amapdata" + aspectid];

            if (!method) {
                setTimeout(init, 200);
                return;
            }
            getpara()
            mapInit();
            initdata();
            $("form").submit(function (e) {
                tojson();
            });
        }

        $().ready(function (e) {
            if (typeof AMap == "undefined") {
                document.write("高德地图接口错误，请与系统管理员联系");
                return;
            }
            init();
        })
    </script>
    <style>
        #map  font{ font-size:12px;}
        #map { font-size:12px;}
    </style>
    <div id="map" ></div>
    <input type="hidden" name="hidData" id="hidData" />
    <input type="hidden" name="hidCenterLat" id="hidCenterLat" />
    <input type="hidden" name="hidCenterLng" id="hidCenterLng" />
    <input type="hidden" name="hidZoom" id="hidZoom" />
    </form>
</body>
</html>
